package com.chenjim.architecture.ui.widget

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.chenjim.architecture.ui.theme.titleStyle

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopAppBarExt(
    @DrawableRes iconRes: Int,
    title: String,
    onClickIcon: () -> Unit
) {
    val customTopAppBarColors =
        TopAppBarDefaults.centerAlignedTopAppBarColors(
            containerColor = Color.White
        )
    CenterAlignedTopAppBar(
        title = {
            Text(
                text = title,
                color = Color(0XFF030303),
                style = titleStyle
            )
        },
        navigationIcon = {
            IconButton(onClick = onClickIcon) {
                Icon(
                    painter = painterResource(id = iconRes),
                    contentDescription = "TopAppBarExt",
                    modifier = Modifier
                        .size(44.dp)
                        .padding(10.dp)
                )
            }
        },
        colors = customTopAppBarColors
    )
}